
/*
 * Copyright (c) 2012 Reksoft
 */
/**
 * @author Reksoft / Vasiliy Beglyanin
 *
 */
package org.sensice.matrioshkaAC.core
import scala.xml.XML
import scala.xml.Node
object RingSheduler {

  var rings = List[AlarmRing]()

  def getFromXML(xmlFile: String) {

  }
  
  def putToXML(xmlFile: String) {

    var xmlRings: List[Node] = List.empty
    for (e <- rings) {
      var xmlr =
        <ring>
          <id>{ e.id }</id>
          <shedule>{ e.shedule.sheduleString }</shedule>
          <active>{ e.active }</active>
          <ringtone>
            <path>{ e.path }</path>
            <type>{ e.ringType }</type>
          </ringtone>
          <vibration>{ e.vibration }</vibration>
        </ring>
      xmlRings ++= xmlr
    }

    val data = <rings>
                 {xmlRings.map(e => e)}
               </rings>
    XML.save(xmlFile,data)
  }

  def initialize(configFile: String) {
    getFromXML(configFile)
  }

  def getNextRings(): (List[AlarmRing], Int) = {
    (rings, 1)
  }
  
  def removeRingById(id: Int) {

  }
}